package com.example.cityiot.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.cityiot.R;

import java.util.List;

/**
 * @ProjectName: CityIOT
 * @Package: com.example.cityiot.adapter
 * @ClassName: MenuAdapter
 * @Description: java类作用描述
 * @Author: 罗文涛
 * @CreateDate: 12/29/21 4:30 PM
 */
public class LeftMenuAdapter extends ArrayAdapter<String> {

    private Context context;
    private int resourceId;


    public LeftMenuAdapter(@NonNull Context context, int resource, @NonNull List<String> objects) {
        super(context, resource, objects);
        this.context = context;
        this.resourceId = resource;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        String msg = getItem(position);
        View view = LayoutInflater.from(context).inflate(resourceId,null);
        TextView menuListItemTvTitle = view.findViewById(R.id.menu_list_item_tv_title);
        menuListItemTvTitle.setText(msg);
        return view;
    }
}
